<?php

$data = null;
$action = null;
$id = null;
$query_select_class = "SELECT * FROM tbl_classes;";
$resultClass = mysql_query($query_select_class) or die('select filter error');
if (isset($_GET['action']) && $_GET['action'] == "edit") {

    $id = $_GET['id'];

    $resultStudent = "SELECT * FROM tbl_students stu WHERE stu_id=" . $id;

    $querySelectWhere = mysql_query($resultStudent) or die('select filter error');

    $data = mysql_fetch_array($querySelectWhere);

    //$action = "controls/edit.php?action=edit&id=".$id;
}
?>

<center>
    <script src="scripts/formValidat.js" type="text/javascript"></script>
    <div id="register_form">
        <form name="fromRegistor"  onsubmit=" return checkForm()" enctype="multipart/form-data" action="controls/action.php?id=<?php echo $id ?>" method="post">

            <div id="sub_title">
                Member Registation
                <hr id="line" />
            </div>
            <div id="content_table">
                <table width="100%" border="0">
                    <tr>
                        <td colspan="2" class="subtitle">
                        <div>
                            Account info....................................
                        </div></td>
                    </tr>
                    <tr>
                        <td width="94">Name:</td>
                        <td width="296">
                        <input id="require_1" type="text"  name="user_name"
                        value="<?php echo $data['user_name']?>" />
                        <span id="txt1" style="color:#FF0000">*</span></td>
                    </tr>
                    <tr>
                        <td>Password:</td>
                        <td>
                        <input type="password" id="require_2"  name="user_pass" value="" />
                        <span id="txt2" style="color:#FF0000">*</span></td>
                    </tr>
                    <tr>
                        <td>Conform:</td>
                        <td>
                        <input type="password" id="require_3" name="user_confirm_pass" value="" />
                        <span id="txt3" style="color:#FF0000">*</span></td>
                    </tr>
                    <tr>
                        <td>Class:</td>
                        <td>
                        <select style="height: 24px; margin-top: 0px;">
                            <option value="">Please select...</option>
                            <?php
                            while ($class_row = mysql_fetch_array($resultClass)) {

                                echo "<option value='$class_row[cla_id]'>$class_row[cla_name] </option>";
                            }
                            ?>
                        </select>
                        <div class="post">
                            <a href="#login-box" class="login-window"><img width="15" class="login-window" style="cursor:pointer" height="15" src="images/icons/add.png" title="Add new class" /></a>
                        </div>
                        
                        
                      </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="subtitle">
                        <div>
                            Student info....................................
                        </div></td>
                    </tr>
                    <tr>
                        <td width="94">First Name:</td>
                        <td width="296">
                        <input id="require_4" type="text" name="firstname"  value="<?php echo $data['stu_first_name']?>" />
                        <span id="txt4" style="color:#FF0000">*</span></td>
                    </tr>
                    <tr>
                        <td>Last Name:</td>
                        <td>
                        <input type="text" id="require_5" name="lastname"  value="<?php echo $data['stu_last_name']?>" />
                        <span id="txt5" style="color:#FF0000">*</span></td>
                    </tr>
                    <tr>
                        <td>Sex:</td>
                        <td>
                        <select name="sex">
                            <option value=""
                            <?php echo(($data['stu_sex']==null)?'selected="selected"':'')?>>Plese select...</option>
                            <option value="M" <?php echo (($data['stu_sex']=="M")? 'selected=selected' : "" ) ?> >Male</option>
                            <option value="F" <?php echo (($data['stu_sex']=="F")?'selected=selected':'')?>>Female</option>
                        </select></td>
                    </tr>
                    <tr>
                        <td>Telephone:</td>
                        <td>
                        <input type="text" name="phone" value="<?php echo $data['stu_telephone']?>" />
                        </td>
                    </tr>
                    <tr>
                        <td>Email:</td>
                        <td>
                        <input type="text" id="require_6" name="email" value="<?php echo $data['stu_email']?>" />
                        <span id="txt6" style="color:#FF0000">*</span></td>
                    </tr>
                    <tr>

                        <td>Photo:</td>
                        <td>
                        <input type="file" name="photo" accept="image/*"/>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                        <input type="reset" />
                        <input type="submit" value="<?php echo (($id!=null)?'Update':'Save')?>" />
                        </td>
                    </tr>
                </table>
            </div>
        </form>
        <br>
        <br>
    </div>
    <a href="#" id="try-1" class="try sprited">Try it!</a>
    
    <div style="display: none; left: 50%; margin-left: -223px; z-index: 1002; position: fixed; top: 50%; margin-top: -159px;" id="sign_up">
                <h3 id="see_id" class="sprited">Can I see some ID?</h3>
                <span>Please sign in using the form below</span>
                <div id="sign_up_form">
                    <label><strong>Username:</strong> <input class="sprited"></label>
                    <label><strong>Password:</strong> <input class="sprited"></label>
                    <div id="actions">
                        <a class="close form_button sprited" id="cancel" href="#">Cancel</a>
                        <a class="form_button sprited" id="log_in" href="#">Sign in</a>
                    </div>
                </div>
                <h3 id="left_out" class="sprited">Feeling left out?</h3>
                <span>Don't be sad, just <a href="#">click here</a> to sign up!</span>
                <a id="close_x" class="close sprited" href="#">close</a>
            </div><div style="height: 2927px; position: absolute; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; z-index: 1001; background: none repeat scroll 0% 0% black; opacity: 0.3; display: none;" class="lb_overlay js_lb_overlay"></div>
</center>